<template>
  <div>
    <div style="height: 510px">
      <el-table
        :data="pageInfo.list"
        size="small"
        style="width: 100%">
        <el-table-column
          label="开始时间"
          prop="startTime">
        </el-table-column>
        <el-table-column
          label="结束时间"
          prop="endTime">
        </el-table-column>
        <el-table-column
          label="执行记录"
          prop="executeProcessName">
          <template slot-scope="scope">
            <el-popover trigger="hover" placement="top">
              <p>执行处理信息: {{ scope.row.executeProcessMsg }}</p>
              <span slot="reference" class="name-wrapper">
                  <el-button v-if="scope.row.executeProcessStatus===0" icon="el-icon-minus" circle
                             size="mini"></el-button>
                  <el-button type="success" v-if="scope.row.executeProcessStatus===1" icon="el-icon-check" circle
                       size="mini"></el-button>
                  <el-button type="danger" v-if="scope.row.executeProcessStatus===2" icon="el-icon-close" circle
                       size="mini"></el-button>
                </span>
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column
          label="采集记录"
          prop="acquisitionProcessStatusName">
          <template slot-scope="scope">
            <el-popover trigger="hover" placement="top">
              <p>采集处理信息: {{ scope.row.acquisitionProcessMsg }}</p>
              <span slot="reference" class="name-wrapper">
                  <el-button v-if="scope.row.acquisitionProcessStatus===0" icon="el-icon-minus" circle
                             size="mini"></el-button>
                  <el-button type="success" v-if="scope.row.acquisitionProcessStatus===1" icon="el-icon-check" circle
                       size="mini"></el-button>
                  <el-button type="danger" v-if="scope.row.acquisitionProcessStatus===2" icon="el-icon-close" circle
                       size="mini"></el-button>
                </span>
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column
          label="检查记录"
          width="180">
          <template slot-scope="scope">
            <span v-for="(item,index) in scope.row.checkRecordDTOList" :key="index">
              <el-popover trigger="hover" placement="top">
                <p>检查摘要: {{ item.checkSummary }}</p>
                <p>检查处理信息: {{ item.checkProcessMsg }}</p>
                <span slot="reference" class="name-wrapper">
                  <el-button v-if="item.checkProcessStatus===0" icon="el-icon-minus" circle
                             size="mini"></el-button>
                  <el-button type="success" v-if="item.checkProcessStatus===1" icon="el-icon-check" circle
                         size="mini"></el-button>
                  <el-button type="danger" v-if="item.checkProcessStatus===2" icon="el-icon-close" circle
                         size="mini"></el-button>
                </span>
              </el-popover>
            </span>
          </template>
        </el-table-column>
        <el-table-column
          label="通知记录"
          width="180">
          <template slot-scope="scope">
            <span v-for="(item,index) in scope.row.msgRecordDTOList" :key="index">
              <el-popover trigger="hover" placement="top">
                <p>消息类型: {{ item.msgTypeName }}</p>
                <p>消息内容: {{ item.msgContent }}</p>
                 <p>消息处理信息: {{ item.msgProcessMsg }}</p>
                <span slot="reference" class="name-wrapper">
                  <el-button v-if="item.msgProcessStatus===0" icon="el-icon-minus" circle
                             size="mini">
                  </el-button>
                  <el-button type="success" v-if="item.msgProcessStatus===1" icon="el-icon-check" circle
                               size="mini">
                  </el-button>
                  <el-button type="danger" v-if="item.msgProcessStatus===2" icon="el-icon-close" circle
                               size="mini">
                  </el-button>
                </span>
              </el-popover>
            </span>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination-table">
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageInfo.pageNum"
          :page-size="pageInfo.pageSize"
          :page-sizes="[10, 15, 30, 100]"
          layout="total, sizes, prev, pager, next, jumper"
          :total="pageInfo.total">
        </el-pagination>
      </div>
    </div>
  </div>

</template>

<script>
  import {listRecord} from '@/api/rule/index'

  export default {
    props: {
      executeRuleId: {
        type: Number,
        default: null
      }
    },
    data() {
      return {
        query: {},
        pageInfo: {}
      }
    },
    methods: {
      // 变更每页显示数量
      handleSizeChange(val) {
        let page = {}
        page.pageSize = val
        page.pageNum = this.pageInfo.pageNum
        this.handleFetchData(page)
      },
      // 更换当前页
      handleCurrentChange(val) {
        let page = {}
        page.pageNum = val
        page.pageSize = this.pageInfo.pageSize
        this.handleFetchData(page)
      },
      //
      handleFetchData(page) {
        let query = this.query;
        query.pageInfo = page;
        query.executeRuleId = this.executeRuleId;
        listRecord(query).then(response => {
          this.pageInfo = response.data
        })
      },
      // 查询信息
      handleQueryInfo() {
        this.handleFetchData({
          pageNum: this.pageInfo.pageNum,
          pageSize: this.pageInfo.pageSize
        })
      },
    },
    created() {
      this.pageInfo.pageSize = 10;
      this.handleQueryInfo()
    },
    computed: {},
    components: {}
  }
</script>

<style scoped>
  .col {
    height: 40px;
  }

  .col-dialog {
    height: 50px;
  }

  .col-description {
    height: 70px;
  }

  .col-textarea {
    height: 70px;
  }
</style>
